import Vue from "vue";
import VueRouter from "vue-router";

import Home from "../views/home/index.vue";
import About from "../views/about/index.vue";
Vue.use(VueRouter);

const router = new VueRouter({
  mode: "history",
  routes: [
    {
      //命名路由 push/relace 跳转可以通过路由名称跳转
      name: "Home",
      path: "/home",
      component: Home,
    },
    {
      path: "/about/:id",
      component: About,
      props($route) {
        //这个可以将路由参数通过props的方式结构给该组件
        return {
          ...$route.query,
          ...$route.params,
        };
      },
    },
  ],
});

export default router;
